﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ks.Fs.Entity;
using System.Data;

namespace Ks.Fs.Core.Data.SqlDataProvider.Mapper
{
    public class UserMapper : GenericMapper<User>
    {
        protected override User MapOne(IDataRecord record)
        {
            User obj = new User();

            if (record["Id"] != DBNull.Value)
            {
                obj.Id = Convert.ToInt32(record["Id"]);
            }

            if (record["Username"] != DBNull.Value)
            {
                obj.Username = Convert.ToString(record["Username"]);
            }

            if (record["Password"] != DBNull.Value)
            {
                obj.Password = Convert.ToString(record["Password"]);
            }

            if (record["ImageFileId"] != DBNull.Value)
            {
                obj.ImageFileId = Convert.ToInt32(record["ImageFileId"]);
            }

            if (record["Birthday"] != DBNull.Value)
            {
                obj.Birthday = Convert.ToDateTime(record["Birthday"]);
            } 
            
            if (record["CreatedOn"] != DBNull.Value)
            {
                obj.CreatedOn = Convert.ToDateTime(record["CreatedOn"]);
            } 

            if (record["IsActive"] != DBNull.Value)
            {
                obj.IsActive = Convert.ToBoolean(record["IsActive"]);
            }            
               
            return obj;
        }
    }
}
